﻿@{
    ViewBag.Title = "Kết quả tìm kiếm";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model PagedList.IPagedList<EC_ASS.Models.SearchResultModel>

@using System.Text;
@using PagedList.Mvc;

<div class="container">
    <h4>Kết quả tìm kiếm cho từ khóa "@ViewBag.Key"</h4>
    <ul class="nav nav-pills sort-source" data-sort-id="portfolio" data-option-key="filter">
        <li data-option-value="*" class="active"><a href="#">Tất cả</a></li>
        <li data-option-value=".ao"><a href="#">Áo</a></li>
        <li data-option-value=".quan"><a href="#">Quần</a></li>
        <li data-option-value=".giay"><a href="#">Giày</a></li>
        <li data-option-value=".phukien"><a href="#">Phụ kiện</a></li>
    </ul>
    <hr />
    <div class="row" id="searchResult">
        @if (Model.Count() > 0)
        {
            <ul class="portfolio-list sort-destination" data-sort-id="portfolio">
                @foreach (var item in Model)
                {
                    if ("PA".Equals(item.CategoryPrefix))
                    {
                    <li class="span2 isotope-item ao">
                        <div class="portfolio-item thumbnail">
                            <a href="#" class="thumb-info">
                                <img alt="" src="@Url.Content("~/" + item.ProductResult.Picture)"/>
                                <span class="thumb-info-title">
                                    <span class="thumb-info-inner">@item.ProductResult.Name</span>
                                    <span class="thumb-info-type">@item.ProductResult.Price VNĐ</span>
                                </span>
                                <span class="thumb-info-action">
                                    <span title="Xem chi tiết" href="#" class="thumb-info-action-icon"><i class="icon-link"></i></span>
                                </span>
                            </a>
                        </div>
                    </li>
                    }
                    else if ("PQ".Equals(item.CategoryPrefix))
                    {
                    <li class="span2 isotope-item quan">
                        <div class="portfolio-item thumbnail">
                            <a href="#" class="thumb-info">
                                <img alt="" src="@Url.Content("~/" + item.ProductResult.Picture)"/>
                                <span class="thumb-info-title">
                                    <span class="thumb-info-inner">@item.ProductResult.Name</span>
                                    <span class="thumb-info-type">@item.ProductResult.Price VNĐ</span>
                                </span>
                                <span class="thumb-info-action">
                                    <span title="Xem chi tiết" href="#" class="thumb-info-action-icon"><i class="icon-link"></i></span>
                                </span>
                            </a>
                        </div>
                    </li>
                    }
                    else if ("PG".Equals(item.CategoryPrefix))
                    {
                    <li class="span2 isotope-item giay">
                        <div class="portfolio-item thumbnail">
                            <a href="#" class="thumb-info">
                                <img alt="" src="@Url.Content("~/" + item.ProductResult.Picture)"/>
                                <span class="thumb-info-title">
                                    <span class="thumb-info-inner">@item.ProductResult.Name</span>
                                    <span class="thumb-info-type">@item.ProductResult.Price VNĐ</span>
                                </span>
                                <span class="thumb-info-action">
                                    <span title="Xem chi tiết" href="#" class="thumb-info-action-icon"><i class="icon-link"></i></span>
                                </span>
                            </a>
                        </div>
                    </li>
                    }
                    else
                    {
                    <li class="span2 isotope-item phukien">
                        <div class="portfolio-item thumbnail">
                            <a href="#" class="thumb-info">
                                <img alt="" src="@Url.Content("~/" + item.ProductResult.Picture)"/>
                                <span class="thumb-info-title">
                                    <span class="thumb-info-inner">@item.ProductResult.Name</span>
                                    <span class="thumb-info-type">@item.ProductResult.Price VNĐ</span>
                                </span>
                                <span class="thumb-info-action">
                                    <span title="Xem chi tiết" href="#" class="thumb-info-action-icon"><i class="icon-link"></i></span>
                                </span>
                            </a>
                        </div>
                    </li>
                    }
                }
            </ul>
        }
        else
        {
            <div class="span1 offset"></div>
            <div class="span9 alert alert-info">Không tìm thấy sản phẩm nào.</div>
            <div class="span1 offset"></div>
        }
    </div>
    <div class="row">
        <div class="pagedList pagination-centered">
            @Html.PagedListPager(Model, page => Url.Action("Search", "Home", new { page, key = ViewBag.Key, price = Request.QueryString.Get("price") }), PagedListRenderOptions.PageNumbersOnly)
        </div>
    </div>
</div>



<hr />
<div class="container">
    <h4>Thanh toán</h4>
    <div class="row">
        @Html.Partial("_Payment")
    </div>
</div>

@functions {
    string ToUrlName(string name)
    {
        string stFormD = name.Normalize(NormalizationForm.FormD);
        StringBuilder sb = new StringBuilder();
        for (int ich = 0; ich < stFormD.Length; ich++)
        {
            System.Globalization.UnicodeCategory uc = System.Globalization.CharUnicodeInfo.GetUnicodeCategory(stFormD[ich]);
            if (uc != System.Globalization.UnicodeCategory.NonSpacingMark)
            {
                sb.Append(stFormD[ich]);
            }
        }
        sb = sb.Replace('Đ', 'D');
        sb = sb.Replace('đ', 'd');
        return (sb.ToString().Normalize(NormalizationForm.FormD).ToUpperInvariant().Trim().Replace(" ", "-"));
    }
}
